Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Visual Basic 6 - [HELP]Colorare stringhe in VB
Forum - Visual Basic 6 - [HELP]Colorare stringhe in VB

Avatar
mirkos90 (Normal User)
Rookie


Messaggi: 42
Iscritto: 13/10/2007

Segnala al moderatore
Postato alle 10:11
Venerdì, 29/08/2008
Salve ragazzi XD mi kiedevo (se è gia stato chiesto io non ho trovato alcuna cosa a riguardo, quindi se è già stato kiesto segnalate il link) se è possibile in visual basic creare un highlighter del tipo GeShI in PHP però che funzia all'istante.
Mi spiego molto mejo:
io ho una textarea dove scrivo
<?php
echo("Ciao");
?>
e mentre che scrivo il <?php diventa rosso e grassettato, l'echo diventa blu e le parole dentro le "" diventano rosse..
Sarebbe ancora + comodo se lo script riconoscesse da solo il linguaggio ke si stà scrivendo..

Please mi serve molto questa cosa :)
GRAZIE :k:

Ultima modifica effettuata da mirkos90 il 29/08/2008 alle 10:16
PM Quote
Avatar
antometal (Member)
Guru


Messaggi: 691
Iscritto: 12/09/2007

Segnala al moderatore
Postato alle 10:40
Venerdì, 29/08/2008

PM Quote
Avatar
mirkos90 (Normal User)
Rookie


Messaggi: 42
Iscritto: 13/10/2007

Segnala al moderatore
Postato alle 10:47
Venerdì, 29/08/2008
uhm no, non era quello ke cercavo :S:S:S:S
mi serve una cosa del tipo no-paste instantaneo XD

PM Quote
Avatar
GrG (Member)
Guru^2


Messaggi: 3430
Iscritto: 21/08/2007

Segnala al moderatore
Postato alle 11:20
Venerdì, 29/08/2008
dovresti mettere in un timer un codice che cerchi le parole che desideri (funzione Instr()) e poi le colora.

PM Quote
Avatar
Overflow (Normal User)
Expert


Messaggi: 334
Iscritto: 11/01/2008

Segnala al moderatore
Postato alle 14:59
Venerdì, 29/08/2008
scusate cancellate

Ultima modifica effettuata da Overflow il 29/08/2008 alle 15:02
PM Quote
Avatar
ruggy94 (Member)
Guru


Messaggi: 890
Iscritto: 21/04/2008

Segnala al moderatore
Postato alle 15:02
Venerdì, 29/08/2008
Testo quotato

Postato originariamente da Overflow:

prova questo codice
Testo quotato

Codice quotato da http://www.codeproject.com/KB/vb/webcamcapture.aspx :
Codice sorgente - presumibilmente VB.NET

  1. 'This program check whether webcam is available or not
  2. ' if available then capture and displays in picture box
  3.  
  4. 'Created by Dixanta Bahadur Shrestha
  5. 'Created Date: 12-March-2006
  6.  
  7. 'Programmer does not garuntees if  not functions well
  8.  
  9. Global Const ws_child As Long = &H40000000
  10. Global Const ws_visible As Long = &H10000000
  11.  
  12. Global Const WM_USER = 1024
  13. Global Const wm_cap_driver_connect = WM_USER + 10
  14. Global Const wm_cap_set_preview = WM_USER + 50
  15. Global Const WM_CAP_SET_PREVIEWRATE = WM_USER + 52
  16. Global Const WM_CAP_DRIVER_DISCONNECT As Long = WM_USER + 11
  17. Global Const WM_CAP_DLG_VIDEOFORMAT As Long = WM_USER + 41
  18. Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  19. Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" (ByVal a As String, ByVal b As Long, ByVal c As Integer, ByVal d As Integer, ByVal e As Integer, ByVal f As Integer, ByVal g As Long, ByVal h As Integer) As Long
  20.  
  21. Dim hwdc As Long
  22. Dim startcap As Boolean
  23. Private Sub cmdCapture_Click()
  24. Dim temp As Long
  25.  
  26.   hwdc = capCreateCaptureWindow("Dixanta Vision System", ws_child Or ws_visible, 0, 0, 320, 240, Picture1.hWnd, 0)
  27.   If (hwdc <> 0) Then
  28.     temp = SendMessage(hwdc, wm_cap_driver_connect, 0, 0)
  29.     temp = SendMessage(hwdc, wm_cap_set_preview, 1, 0)
  30.     temp = SendMessage(hwdc, WM_CAP_SET_PREVIEWRATE, 30, 0)
  31.     startcap = True
  32.     Else
  33.     MsgBox ("No Webcam found")
  34.   End If
  35. End Sub
  36.  
  37. Private Sub cmdClose_Click()
  38. Dim temp As Long
  39. If startcap = True Then
  40. temp = SendMessage(hwdc, WM_CAP_DRIVER_DISCONNECT, 0&, 0&)
  41. startcap = False
  42. End If
  43. End Sub
  44.  
  45. Private Sub cmdVideoFormat_Click()
  46.  Dim temp As Long
  47.  If startcap = True Then
  48.   temp = SendMessage(hwdc, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
  49. End If
  50. End Sub





Credo che tu volessi rispondere al post della webcam :D

PM Quote
Avatar
Overflow (Normal User)
Expert


Messaggi: 334
Iscritto: 11/01/2008

Segnala al moderatore
Postato alle 15:07
Venerdì, 29/08/2008
@ruggy94 ...si infatti.

Credo che dovresti avere un database con tutte le parole chiave dei linguaggi, e poi attraverso un timer (come ha detto grg) andare a controllare se nella textarea ci sia una parole che esiste nel database.

PM Quote
Avatar
Overflow (Normal User)
Expert


Messaggi: 334
Iscritto: 11/01/2008

Segnala al moderatore
Postato alle 15:55
Venerdì, 29/08/2008
ti posto il codice che ho fatto, ma bisogna modificarlo un po.

inserisci un richtextbox chiamala (rb) e un timer(timer1).

Codice sorgente - presumibilmente VB.NET

  1. Dim keyWords() As String
  2.  
  3. Private Sub Form_Load()
  4. Dim value As String
  5.  
  6. Open "C:\keywords.txt" For Input As 1
  7. value = Space(LOF(1))
  8. Line Input #1, value
  9.  
  10. Close #1
  11.  
  12. keyWords = Split(value, ",")
  13.  
  14. For i = 0 To UBound(keyWords)
  15.     keyWords(i) = Replace(keyWords(i), " ", "")
  16.     keyWords(i) = LCase(keyWords(i))
  17. Next i
  18.  
  19.  
  20.  
  21.  
  22. End Sub
  23.  
  24. Private Sub Timer1_Timer()
  25. Dim a, pos As Integer
  26. Dim tmp() As String
  27. Dim val As String
  28. val = rb.Text
  29. val = LCase(val)
  30.  
  31. For i = 0 To UBound(keyWords)
  32.     tmp = Split(val, " ")
  33.     For y = 0 To UBound(tmp)
  34.         If (tmp(y) = keyWords(i)) Then
  35.             a = InStr(1, val, keyWords(i))
  36.             pos = rb.SelStart
  37.             rb.SelStart = a - 1
  38.             rb.SelLength = Len(keyWords(i))
  39.             rb.SelColor = vbBlue
  40. rb.font.bold=true
  41.             rb.SelStart = pos
  42.         End If
  43.     Next y
  44.     rb.SelColor = vbBlack
  45. Next i
  46.  
  47. End Sub


Ultima modifica effettuata da Overflow il 29/08/2008 alle 15:59
PM Quote